<style scoped>
.layui-row {
    overflow: hidden;
}

.select-item {
    width: 34.333333%;
    float: right;
}

.layui-row:after,
.layui-row:before {
    clear: none;
}
</style>

<template>
<div class="department">

    <form class="layui-form ">
        <div class="layui-col-lg4 select-item" style="text-align: right;width: auto">
            <div class="layui-inline" style="width: 200px">
                <input type="text" v-model="dailydata" autocomplete="off" name="dailydata" id="dailydata" placeholder="请选择日报日期"  class="layui-input key">
            </div>
            <button type="button" class="layui-btn sou" @click="search">搜索</button>
        </div>
    </form>
    <table class="layui-table layui-form">

        <thead>
            <tr>
                <th>渠道</th>
                <th>月销售计划</th>
                <th>实际订单量</th>
                <th>已发货数量</th>
                <th>待加工</th>
                <th>今日发货量</th>
                <th>今日新增回款（元）</th>
                <th>累计回款（元）</th>
                <th>销售计划完成率</th>
                <th>生产订单完成率</th>
                <th>操作</th>
            </tr>
        </thead>
        <tbody>
            <tr class="id9" v-for="(val, index) in productiondaily" :key="index">
                <td>{{val.dailydate}}</td>
                <td>{{val.orgname}}</td>
                <td>{{val.planname}} </td>
                <td>{{val.departname}} </td>
                <td>{{val.srname}}</td>
                <td>{{val.cost}}</td>
                <td>{{val.income}}</td>
                <td>{{val.profit}}</td>

                <td><a href="javascript:;" @click="toPage(val.guid)">查看详情</a></td>
            </tr>
        </tbody>
    </table>

    <Pagination :cur="currentPage" :all="totalPage" :callback="turnPage"></Pagination>
</div>
</template>

<script>
import Pagination from '../common/Pagination.vue'
let qs = require('qs');
export default {
    name: 'ProductiondailyList',
    components: {
        Pagination
    },

    data() {
        return { 
            currentPage: 1,
            totalPage: 0,
            dailydata: "",
            productiondaily: []
        }
    },
    mounted() {
        let that = this;
        layui.use('laydate', function () {
            var laydate = layui.laydate;
            //执行一个laydate实例
            laydate.render({
                elem: '#dailydata' //指定元素
            });

        });
    },
    methods: {
        search: function () {
            var that =this
            that.dailydata=$('#dailydata').val();
            if(that.dailydata==""){
                that.alert("日报日期不可为空")
                return
            }
            this.$post('/sales/ScheduldailyRpt!getDailyRpt.action', qs.stringify({
                    "date":that.dailydata
                }))
                .then(response => {
                    let data = response.data;
                    if (data.msg == 'true') {
                        that.productiondaily = data
                    } else {
                         that.alert("系统错误");
                    }
                })
        },
        turnPage: function(data){
                this.currentPage = data;
            },
    }
}
</script>
